package com.jfinal.model.auth;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Record;

import java.util.List;

/**
 * Created by xiaoyuan on 2018/1/19.
 */
public class Role extends Model<Role>{
    public static final Role dao = new Role().dao();
    private String findAuths4Role = Db.getSql("auth.findAuths4Role");
    private String findUsersByRole = Db.getSql("auth.findUserByRole");

    /**
     * 获取当前角色的所有权限
     * @return
     */
    public List<Auth> getAuths(){
        return Auth.dao.find(findAuths4Role,get("id"));
    }

    /**
     * 获取当前角色下的所有用户
     * @return
     */
    public List<User> getUsersByRole(){
        return User.dao.find(findUsersByRole,get("id"));
    }
}
